import { Entity, Column, PrimaryColumn, PrimaryGeneratedColumn, OneToOne, ManyToOne, Auth, ManyToMany } from "typeorm";
import { PhotoMetadata } from "./PhotoMetaData";
import { Author } from "./Author";
import { Album } from "./Album";

@Entity()
export class Photo {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ length: 100 })
  name: string;

  @Column('text')
  description: string;

  @Column()
  filename: string;

  @Column('double')
  views: number;

  @Column()
  isPublished: boolean;

  @OneToOne(type => PhotoMetadata, photoMetadata => photoMetadata.photo)
  metadata: PhotoMetadata;

  @Column({ nullable: true })
  authorId: number;

  @ManyToOne(type => Author, author => author.photos)
  author: Author;

  @ManyToMany(type => Album, album => album.photos)
  albums: Album[];
}
